﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.OracleClient;
using BCNPCObject.DB;
using DbLinq;
using DbLinq.Oracle;
using CMISLibrary.Entities;
using CMISLibrary;

namespace BCNPCObject
{
    public class cls_NPC_LOG_CHAMNO_Controller
    {
        #region   Atributes

        private DataSet CMIS_Header = new CMISOutputParameter();
        private DataSet ds = new DataSet();
        private DataTable dt = new DataTable();
        private NPC_LOG_CHAMNO info;

        #endregion

        #region   Constructor

        public cls_NPC_LOG_CHAMNO_Controller()
        {
            info = new NPC_LOG_CHAMNO();
        }
        public cls_NPC_LOG_CHAMNO_Controller(NPC_LOG_CHAMNO Info)
        {
            this.info = Info;
        }

        #endregion

        #region   Properties

        public NPC_LOG_CHAMNO pInfor
        {
            get { return info; }
            set { info = value; }
        }

        #endregion

        #region  DungNT NPC

        public long GetSequence(ref string str)
        {
            try
            {
                long _id = CMIS2.DB.ExecuteCommand("select SEQ_NPC_LOG_CHAMNO.nextval from dual", ref str);
                if (str.Trim().Length > 0) return -1;
                return _id;
            }
            catch
            {
                //CMIS2.ResetDB(); 
                return -1;
            }
        }
        
        public bool insert_NPC_LOG_CHAMNO( ref string str)
        {
        try
            {
                long _ID_LOG = GetSequence(ref str);
            if (_ID_LOG == -1) return false;

                NPC_LOG_CHAMNO objNPC_LOG_CHAMNO = new NPC_LOG_CHAMNO
            {
                MA_DVIQLY = info.MA_DVIQLY,
                ID_LOG = _ID_LOG,
                ID_HDON = info.ID_HDON,
                LOAI_HDON = info.LOAI_HDON,
                MA_GD = info.MA_GD,
                MA_ERRO = info.MA_ERRO,
                NGUOI_TAO = info.NGUOI_TAO,
                NGAY_TAO = info.NGAY_TAO,
                TINH_TRANG = info.TINH_TRANG,
                MA_THAOTAC = info.MA_THAOTAC
            };
                CMIS2.DB.NPC_LOG_CHAMNO.InsertOnSubmit(objNPC_LOG_CHAMNO);
            return true;
            }
            catch
            { 
            return false; 
            }
        }
#endregion
     
    }
}

